<?php
if(!defined('IN_KKFRAME')) exit();
if(!$_GET['skip']) include template('header');
?>

<div class="side">
<div class="side-box">
<?php
if(!$_K['uid'] && !$_GET['skip']){
	include template('side_login');
}elseif(!$_GET['skip']){
	$h = date('H');
	if($h < 1) $greeting = '快睡吧';
	elseif($h < 6) $greeting = '晚安';
	elseif($h < 9) $greeting = '早安';
	elseif($h < 11) $greeting = '早上好';
	elseif($h < 14) $greeting = '中午好';
	elseif($h < 19) $greeting = '下午好';
	elseif($h < 23) $greeting = '晚上好';
	else $greeting = '夜深了';
	echo <<<EOF
<h2>{$greeting}，<b>{$_K[member][username]}</b>！</h2>
<form method="post" action="new.php">
<input type="hidden" name="fid" value="{$fid}" />
<p>在分类 {$_K[config][forums][$fid]} 下发帖：</p>
<p><input type="text" name="subject" required placeholder="在此输入帖子标题"></p>
<p><textarea required name="contents" style="width: 100% !important" onkeydown="if(event.ctrlKey && event.keyCode == 13) document.getElementById('submit').click();"></textarea></p>
<p class="text-right"><input type="submit" id="submit" class="g-button g-button-red" value="发表新帖" /></p>
</form>
EOF;
}
?>
</div>
</div>

<div class="page-info">
<div class="page-headers"><h1><?php echo $_K['config']['forums'][$fid]; ?></h1></div>

<div class="thread-list">
<?php
if($page > 1){
	echo '<a href="?page='.($page - 1).'" id="prev_page_link" onclick="load_prev_page();return false;" class="page_loader">点击加载上一页</a>';
	echo '<div class="page_loader center" id="prev_page_waiter">加载中...</div><div id="prev_page_loader"></div>';
}
echo '<div id="posts">';
foreach($threadlist as $thread){
	$style = $style ? 0 : 1;
	echo '<a href="thread.php?id='.$thread['tid'].'">';
	echo '<div class="thread style_'.$style.' clearfix">';
	echo '<span class="postinfo">作者: '.$thread['author_name'].'<br>最后回复: '.dgmdate($thread['lastpost']).'</span>';
	echo '<h5>'.$thread['subject'].'</h5></div></a>';
}
echo '</div>';
if($max_page > $page){
	echo '<div id="next_page_loader"></div><div class="page_loader center" id="next_page_waiter">加载中...</div>';
	echo '<a href="?page='.($page + 1).'" id="next_page_link" class="page_loader text-right" onclick="load_next_page();return false;">点击加载下一页</a>';
}
?>
</div>

</div>

<?php
$_K['footer_js'] .= '<script type="text/javascript" src="system/javascript/replyto.js"></script><script type="text/javascript" src="system/javascript/kk_pager.js"></script><script type="text/javascript">var next_page = '.($page + 1).';var prev_page = '.($page - 1).';var max_page = '.$max_page.';var page_temp = "forum.php?fid='.$fid.'"</script>';
if(!$_GET['skip']) include template('footer');